package com.activity.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import com.activity.dao.GoodsDao;
import com.activity.model.Goods;
@Component
public class GoodsDaoImpl extends SqlSessionDaoSupport implements GoodsDao {

	@Resource
	@Override
	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		// TODO Auto-generated method stub
		super.setSqlSessionFactory(sqlSessionFactory);
	}
	@Override
	public boolean SaveGoods(Goods goods) {
		SqlSession session = getSqlSession();
		String statement = "com.activity.mapper.GoodsMapper.saveGoods";
		int result = session.insert(statement, goods);
		return result == 1 ? true : false;
	}
	@Override
	public List<Goods> queryGoods() {
		SqlSession session = getSqlSession();
		String statement = "com.activity.mapper.GoodsMapper.queryGoods";
		List<Goods> list =session.selectList(statement);
		System.out.println(list.get(0));
		return list;
	}

}
